package com.iknow.ui.model;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.iknow.xmpp.service.Contact;
import java.util.List;

public class XmppFriendAdapter extends BaseAdapter
{
  private Context mContext;
  private LayoutInflater mInflater = null;
  private List<Contact> mListContact;

  public XmppFriendAdapter(Context paramContext, LayoutInflater paramLayoutInflater)
  {
    this.mInflater = paramLayoutInflater;
    this.mContext = paramContext;
  }

  private void fillDataToView(int paramInt, View paramView)
  {
    Contact localContact = (Contact)this.mListContact.get(paramInt);
    ViewHoler localViewHoler = (ViewHoler)paramView.getTag();
    localViewHoler.mUserName.setText(localContact.getName());
    localViewHoler.mSignature.setText(localContact.getMsgState());
  }

  private View newView()
  {
    ViewHoler localViewHoler = new ViewHoler(this, null);
    View localView = this.mInflater.inflate(2130903060, null);
    localViewHoler.mUserHead = ((ImageView)localView.findViewById(2131296338));
    localViewHoler.mUserName = ((TextView)localView.findViewById(2131296287));
    localViewHoler.mSignature = ((TextView)localView.findViewById(2131296330));
    localView.setTag(localViewHoler);
    return localView;
  }

  public int getCount()
  {
    return this.mListContact.size();
  }

  public Contact getItem(int paramInt)
  {
    return ((Contact)this.mListContact.get(paramInt));
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    if (paramView == null)
      paramView = newView();
    fillDataToView(paramInt, paramView);
    return paramView;
  }

  public void setContactList(List<Contact> paramList)
  {
    this.mListContact = paramList;
  }

  private class ViewHoler
  {
    public TextView mDistance;
    public ImageView mIsFriend;
    public TextView mSignature;
    public ImageView mUserHead;
    public TextView mUserName;
  }
}